package com.mz.mattress.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mz.mattress.admin.api.resp.MemberCount;
import com.mz.mattress.api.entity.Order;
import com.mz.mattress.api.entity.SummaryTimes;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderMapper extends BaseMapper<Order> {

    IPage<Order> listPage(Page page,
                          @Param("mobile") String mobile,
                          @Param("status") Integer status,
                          @Param("orderId") String orderId,
                          @Param("goodsId") Integer goodsId,
                          @Param("coupon") Integer coupon,
                          @Param("startTime") String startTime,
                          @Param("endTime") String endTime);

    SummaryTimes listTotal(
            @Param("mobile") String mobile,
            @Param("status") Integer status,
            @Param("orderId") String orderId,
            @Param("goodsId") Integer goodsId,
            @Param("coupon") Integer coupon,
            @Param("startTime") String startTime,
            @Param("endTime") String endTime);

    @Select("SELECT member_id,count(*) from mz_order WHERE deleted=0 and `status` in (2,3) GROUP BY member_id")
    List<MemberCount> sumMemberOrderCount();

}
